package com.lyf.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.lyf.dao.TasktypeDao;
import com.lyf.pojo.Tasktype;
import com.lyf.util.DateUtil;

@Service
@Transactional
public class TasktypeService {

	@Autowired
	private TasktypeDao dao;
	
	//save
	public void save(Tasktype tasktype){
		tasktype.setCreatetime(DateUtil.getNow());
		tasktype.setColor("c50000");
		dao.saveOrUpdate(tasktype);
	}

	
	@Transactional(readOnly=true)
	public List<Tasktype> findAll() {
		return dao.findAllByOrder("desc", "createtime");
	}

	public void deleteById(String typeid) {
		dao.delete(typeid);
	}

	public void changeColor(String color, String typeid) {
		dao.updateColor(color, typeid);
	}
	
	public void changType(String type, String typeid) {
		dao.updateType(type,typeid);
	}

	
}
